// <copyright file="ButtonDesigner.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System;
using System.Globalization;
using System.IO;
using System.Web.UI;
using System.Web.UI.Design;

[assembly: WebResource("YUIAspNet.Design.regularButton.png", "image/png")]

namespace YUIAspNet
{
    /// <summary>
    /// Designer class for button control.
    /// </summary>
    public class ButtonDesigner : ControlDesigner
    {
        protected ButtonDesigner()
        {
        }

        /// <summary>
        /// Retrieves the HTML markup that is used to represent the control at design time.
        /// </summary>
        /// <returns>
        /// The HTML markup used to represent the control at design time.
        /// </returns>
        public sealed override string GetDesignTimeHtml()
        {
            Stream inputStream = this.GetType().Assembly.GetManifestResourceStream("YUIAspNet.Design.regularButton.png");

            if (inputStream != null)
            {
                System.Drawing.Image img = System.Drawing.Image.FromStream(inputStream);

                string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ((Control) this.Component).ClientID);

                fileName += ".png";

                img.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);

                return string.Format(CultureInfo.InvariantCulture, "<img src='{0}' />", fileName);
            }

            return "&nbsp;";
        }
    }
}
